package com.lilicould.controller;

import com.lilicould.entity.Apartment;
import com.lilicould.entity.House;
import com.lilicould.service.HouseService;
import com.lilicould.service.impl.HouseServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/house")
public class HouseController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HouseService houseService = new HouseServiceImpl();
        ArrayList<House> houses = houseService.selectAllHouses();
        req.setAttribute("houses", houses);
        req.getRequestDispatcher("/page/house.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
